import { defHttp } from '/@/utils/http/axios';
import {
  OpmsFixFamilyInfoListGetResultModel,
  OpmsFixFamilyInfoModel,
  OpmsFixFamilyInfoPageListGetResultModel,
  OpmsFixFamilyInfoParams,
  OpmsFixFamilyInfoPageSearchParams,
  OpmsFixFamilyInfoListSearchParams,
  UpdateOpmsFixFamilyInfoParams,
  OpmsFixFamilyInfoIDType,
} from '/@/api/opms/model/OpmsFixFamilyInfoModel';

import { UploadFileParams } from '/#/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { UploadApiResult } from '../sys/model/uploadModel';

// 常住家庭信息表接口
export enum Api {
  PublicApi = '/opms/opms-fix-family-info',
  ListApi = `/opms/opms-fix-family-info/list`,
  PageApi = `/opms/opms-fix-family-info/page`,
  BatchApi = `/opms/opms-fix-family-info/batch`,
  ExportApi = `/opms/opms-fix-family-info/export`,
  ImportApi = `/opms/opms-fix-family-info/import`,
}
/**
 * @description:  获取列表
 * @param params
 * @returns
 */
export const getOpmsFixFamilyInfoList = (params?: OpmsFixFamilyInfoListSearchParams) =>
  defHttp.get<OpmsFixFamilyInfoListGetResultModel>({ url: Api.ListApi, params });

/**
 * @description:  分页获取列表
 * @param params
 * @returns
 */
export const getOpmsFixFamilyInfoPage = (params: OpmsFixFamilyInfoPageSearchParams) =>
  defHttp.get<OpmsFixFamilyInfoPageListGetResultModel>({ url: Api.PageApi, params });

/**
 * @description:  根据id获取
 * @param id
 * @returns
 */
export const getOpmsFixFamilyInfo = (id: OpmsFixFamilyInfoIDType) =>
  defHttp.get<OpmsFixFamilyInfoModel>({ url: `${Api.PublicApi}/${id}` });

/**
 * @description:  创建
 * @param params
 * @returns
 */
export const createOpmsFixFamilyInfo = (params: OpmsFixFamilyInfoParams) =>
  defHttp.post<boolean>({ url: Api.PublicApi, params });

/**
 * @description:  更新
 * @param params
 * @returns
 */
export const updateOpmsFixFamilyInfo = (params: UpdateOpmsFixFamilyInfoParams) =>
  defHttp.put<boolean>({ url: Api.PublicApi, params });

/**
 * @description:  物理删除
 * @param id
 * @returns
 */
export const deleteOpmsFixFamilyInfo = (id: OpmsFixFamilyInfoIDType) =>
  defHttp.delete<boolean>({ url: `${Api.PublicApi}/${id}` });

/**
 * @description:  物理批量删除
 * @param ids
 * @returns
 */
export const deleteOpmsFixFamilyInfoBatch = (ids: OpmsFixFamilyInfoIDType[]) =>
  defHttp.post<boolean>({ url: Api.BatchApi, params: { ids } });

/**
 * @description:  逻辑删除
 * @param ids
 * @returns
 */
export const logicDeleteOpmsFixFamilyInfo = (id: OpmsFixFamilyInfoIDType) =>
  defHttp.delete<boolean>({ url: `${Api.PublicApi}/${id}` });

/**
 * @description:  逻辑批量删除
 * @param ids
 * @returns
 */
export const logicDeleteOpmsFixFamilyInfoBatch = (ids: OpmsFixFamilyInfoIDType[]) =>
  defHttp.post<boolean>({ url: Api.BatchApi, params: { ids } });

/**
 * @description:  导出文件
 * @param ids
 * @returns
 */
export const exportOpmsFixFamilyInfoListFile = (ids: OpmsFixFamilyInfoIDType[]) =>
  defHttp.post<boolean>({ url: Api.ExportApi, params: { ids } });

/**
 * @description:  导入文件
 * @param ids
 * @returns
 */
export const importOpmsFixFamilyInfoListFile = (
  params: UploadFileParams,
  onUploadProgress?: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: useGlobSetting().apiUrl + Api.ImportApi,
      onUploadProgress,
    },
    params,
  );
